package uk.ac.salfordcc.sccmobile;

import android.annotation.TargetApi;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import android.view.View;

public class SMSActivity extends Activity {
    private String sccUsername;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_sms);
		// Show the Up button in the action bar.
		setupActionBar();

        SharedUtilities util = new SharedUtilities(getApplicationContext());
        sccUsername = util.getStoredPreference("USERNAME");
	}

	/**
	 * Set up the {@link android.app.ActionBar}.
	 */
    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    private void setupActionBar() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            getActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.sm, menu);
		return true;
	}

    public boolean onOptionsItemSelected(MenuItem item){
        switch(item.getItemId()){
            case R.id.action_exitapp:
                SharedUtilities.endApplication(this, SMSActivity.this);
                return true;
            case R.id.action_settings:
                Intent intent = new Intent(SMSActivity.this, SettingsActivity.class);
                startActivity(intent);
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }
    public void openMyStudents(View view){
        Intent intent = new Intent(SMSActivity.this, MyStudentsActivity.class);
        startActivity(intent);
    }

}
